import request from '@/utils/request'

export function add(data) {
  return request({
    url: 'purchase/add',
    method: 'post',
    data
  })
}

export function del(ids) {
  return request({
    url: 'purchase/delete',
    method: 'delete',
    data: ids
  })
}

export function edit(data) {
  return request({
    url: 'purchase/update',
    method: 'put',
    data
  })
}

export function page() {
  return request({
    url: 'purchase/page',
    method: 'get'
  })
}

export function audit(ids) {
  return request({
    url: 'purchase/audit',
    method: 'put',
    params: ids
  })
}
export function receive(params) {
  return request({
    url: 'purchase/receive',
    method: 'PUT',
    params: params
  })
}

export function priceCheck(productId) {
  return request({
    url: 'purchase/priceCheck',
    method: 'get',
    params: productId
  })
}

export function getOne(id) {
  return request({
    url: '/purchase/' + id,
    method: 'get',
    data: id
  })
}

export function exportExcel(id) {
  return request({
    url: '/purchase/exportPurchase',
    method: 'get',
    params: id,
    responseType: 'blob'
  })
}

export default { add, edit, del, page, audit, getOne, receive, exportExcel }
